package com.example.jqying.androiddemo.main;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.jqying.androiddemo.R;
import com.example.jqying.androiddemo.fragment.ContainerActivity;
import com.example.jqying.androiddemo.jump.AActivity;
import com.example.jqying.androiddemo.loadimage.LoadImageActivity;
import com.example.jqying.androiddemo.popupWindow.PopupWindowActivity;
import com.example.jqying.androiddemo.recyclerView.activity.RecyclerViewActivity;
import com.example.jqying.androiddemo.strategy.StrategyActivity;
import com.example.jqying.androiddemo.vistorPattern.VistorActivity;
import com.example.jqying.androiddemo.webview.WebVIewActivity;

public class MainActivity extends AppCompatActivity {

    private final String TAG = ">>>>>MainActivity<<<<<";
    private Button mBtnJump;
    private Button mLoadImage;
    private Button mBtnRv;
    private Button mBtnWebView;
    private Button mBtnPopupWindow;
    private Button mBtnFragment;
    private Button mBtnStrategy;
    private Button mBtnVistor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*
        Activity 跳转示例
         */
        mBtnJump = (Button) findViewById(R.id.btn_jumpExample);
        mBtnJump.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //显式跳转
                Log.i(TAG,"mBtnJump onClick");
                Intent intent = new Intent(MainActivity.this, AActivity.class);
                startActivity(intent);
            }
        });
        /*
        *   使用第三方库通过网络加载图片
         */

        mLoadImage = (Button) findViewById(R.id.btn_loadImage);
        mLoadImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Log.i(TAG,"mLoadImage onClick");
                Intent intent = new Intent(MainActivity.this, LoadImageActivity.class);
                startActivity(intent);
            }
        });


        /*
        *   RecycleView 示例
         */

        mBtnRv = (Button) findViewById(R.id.btn_recycleView);
        mBtnRv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, RecyclerViewActivity.class);
                startActivity(intent);
            }
        });

        /*
        *   WebView 测试
        *
         */

        mBtnWebView = (Button) findViewById(R.id.btn_webView);
        mBtnWebView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, WebVIewActivity.class);
                startActivity(intent);
            }});

        /*
        *   popupWindows 测试
        *
         */

        mBtnPopupWindow = (Button) findViewById(R.id.btn_pop);
        mBtnPopupWindow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, PopupWindowActivity.class);
                startActivity(intent);
            }
        });

        /*
        *   fragment 测试
        *
         */

        mBtnFragment= (Button) findViewById(R.id.btn_fragment);
        mBtnFragment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, ContainerActivity.class);
                startActivity(intent);
            }
        });

        /*
        *   策略模式
        *
         */

        mBtnStrategy = (Button) findViewById(R.id.btn_strategy);
        mBtnStrategy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, StrategyActivity.class);
                startActivity(intent);
            }
        });


        /*
        *   访问者模式
        *
         */

        mBtnVistor = (Button) findViewById(R.id.btn_vistor);
        mBtnVistor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, VistorActivity.class);
                startActivity(intent);
            }
        });

    }
}














